/* pfsFFKick.cpp
 *
 * --
 * Copyright (c) 2012, Christophe Huriaux
 * Distributed under the terms of the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * --
 */

#include <packet/pfsFFKick.h>
#include <wrapper/JavaStreamWrapper.h>

pfsFFKick::pfsFFKick()
    : McPacketFromServer(0xFF), reason("")
{
}

unsigned int pfsFFKick::length()
{
    return 1 + 2 + reason.length();
}

int16_t pfsFFKick::setField(uint8_t field, void* value)
{
    static int16_t slen;

    switch (field)
    {
        case 0:
        default: return 2;
        case 1: slen = JavaStreamWrapper::readShort(value); return 2*slen;
        case 2: reason = JavaStreamWrapper::readUTF(value, slen); return -1;
    }
}

std::string pfsFFKick::getReason()
{
    return reason;
}


